<?php
class universityModel extends appModel{
    
    protected function init(){
        
    }
    public function getCountry(){       
        $data = array();
        $start = isset($_GET['start']) ? $_GET['start'] : 0;
        $limit = isset($_GET['limit']) ? $_GET['limit'] : 10;
        $query = "SELECT * FROM `country` ORDER BY `name`LIMIT {$start},{$limit}";
        $result = $this->db->query($query);
        $nbrows = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM `country`"));
        $nbrows = $nbrows[0];
        while($row=$this->db->fetchAssoc($result)){
            $data[]=$row;
        }
// print_r($data);
        if(MyHelpers::isAjax()){
            $ret['metaData'] =   $this->makeMetaData($result);
            $ret['total']    =   $nbrows;
            $ret['data']     =   $this->Char2Utf8($data);
            $ret['success']  =   true;
            $ret['message']  =   true;
            return json_encode($ret);
        }

        return $data;       
    }
    public function universityname($id=null,$create_date,$modified,$name,$country_id){
        if($id == null || $id == ""){      
        $result = $this->db->query("INSERT INTO university (create_date, name, country_id) VALUES ('$create_date', '$name', '$country_id')");
    }else{
        $result = $this->db->query("UPDATE `university` SET `modified`='$modified', `name`='$name', `country_id`='$country_id' WHERE `id`='$id'");
    }
        if($result != false){
            $id = $this->db->insertId();
        }

        return $id;
    }

}
?>